package com.starblink.android.basic.ext

import android.annotation.SuppressLint
import android.content.res.Resources
import java.text.DecimalFormat
import java.util.Objects.isNull
import java.util.regex.Pattern

/*converts dp value into px*/
val Number.dp
    get() = (this.toFloat() * Resources.getSystem().displayMetrics.density).toInt()

/*converts sp value into px*/
val Number.sp
    get() = (this.toFloat() * Resources.getSystem().displayMetrics.scaledDensity).toInt()


fun Int.toThousDigitsStr(): String {
    var result = ""
    val tmp = this.toString()

    if (tmp.length <= 3) {
        return tmp
    }

    var lastIndex = tmp.length

    while (lastIndex - 3 >= 0) {
        result = "," + tmp.substring(lastIndex - 3, lastIndex) + result
        lastIndex -= 3
    }
    result = tmp.substring(0, lastIndex) + result

    return result
}



